from pydantic import BaseModel, Field
from typing import Optional


class SimpleUser(BaseModel):
    username: str
    screen_name: str
    role: str
    description: Optional[str]


class NewUser(SimpleUser):
    pass


class UserInList(SimpleUser):
    pass


class Token(BaseModel):
    code: int = 0
    access_token: str = Field(description='本次登录的token')
    token_type: str = Field(default='Bearer', description='token的类型，统一为 Bearer')
    user_role: str = Field(title='用户的角色，common 或者 admin', regex='(common)|(admin)')


class DeleteResult(BaseModel):
    delete_count: int = Field(title='删除的个数，0 则表示原数据库中没有该用户')


class UpdateResult(BaseModel):
    matched_cnt: int = Field(title='本次更新所匹配的记录个数')
    modified_cnt: int = Field(title='本次更新所修改的记录个数')
